<template>
    <div class="profit">
        <van-nav-bar :title="$t('node.detail')" leftArrow @click-left="_return" />
        <van-tabs class="tabs" v-model="active" color="#666" title-inactive-color="#666" title-active-color="#22c196"  @change="tabChange">
            <van-tab v-for="(item,index) in $t('node.tab')" :title="item" :key="item.index" v-if="index<=1"></van-tab>
        </van-tabs>
        <div class="profitMain">
            <ul>
                <li v-for="item in list" :key="list.index">
                    <van-row type="flex" justify="space-between">
                        <van-col>
                            <p>{{$t('node.tab')[active]}}</p>
                            <span>{{item.add_time}}</span>
                        </van-col>
                        <van-col>
                            <p>+ {{Number(item.usdtnum).toFixed(2)}} USDT</p>
<!--                            <span>≈ {{item.num}} {{item.coin_name}}</span>-->
                        </van-col>
                    </van-row>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
    import moment from 'moment'
    export default {
        data() {
            return {
                active:0,
                list:[]
            }
        },
        methods: {
            _return(){
                this.$emit('_return')
            },
            getData(){
                this.$api.post('node/proFit',{tid:this.active})
                    .then(res =>{
                        this.list = res.detail.list
                        this.list.map(item => item.add_time = moment(item.add_time*1000).format('YYYY.MM.DD'))
                    })
            },
            tabChange(){
                this.getData()
            }
        },
        created() {
            this.getData()
        },
        mounted() {

        },
    }
</script>

<style lang="stylus" scoped>
    [class*=van-hairline]::after{
        border: none;
    }
    .van-tabs
        [class*=van-hairline]::after
            border: none
    .profitMain
        ul
            margin-top 25px
            li
                padding 15px
                margin-bottom 5px
                border-bottom 1px solid #ebebeb
                .van-col
                    p
                        font-size 16px
                        color #D8D8D8
                    span
                        display inline-block
                        margin-top 5px
                        color #898989
                        font-size 12px
                    &:last-child
                        text-align right
                        p
                            color #22c196

</style>
